package com.bw.mvvm.network.inteceptor;

import com.blankj.utilcode.util.SPUtils;
import com.bw.mvvm.utils.SpUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class TokenInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        String s = SpUtils.readToken();
        Request.Builder builder = new Request.Builder();
        builder.url(request.url());
        builder.headers(request.headers());
        builder.addHeader("token",s);
        builder.post(request.body());
        return chain.proceed(builder.build());
    }
}
